//编写一个函数，不用临时变量，直接交换numbers = [a, b]中a与b的值。 
//
// 示例： 
//
// 
//输入: numbers = [1,2]
//输出: [2,1]
// 
//
// 提示： 
//
// 
// numbers.length == 2 
// -2147483647 <= numbers[i] <= 2147483647 
// 
//
// Related Topics 位运算 数学 👍 108 👎 0


package LeetCode.editor.cn;

/**
 * @author ldltd
 * @date 2025-09-05 00:01:29
 * @description 面试题 16.01.交换数字
 */
public class SwapNumbersLcci{
	 public static void main(String[] args) {
	 	 //测试代码
	 	 SwapNumbersLcci fun=new SwapNumbersLcci();
	 	 Solution solution = fun.new Solution();

	 }
	 
//力扣代码
//leetcode submit region begin(Prohibit modification and deletion)
class Solution {
    public int[] swapNumbers1(int[] numbers) {
        numbers[0]+=numbers[1];
		numbers[1]=numbers[0]-numbers[1];
		numbers[0]=numbers[0]-numbers[1];
		return numbers;
    }
	public int[] swapNumbers(int[] numbers) {
		numbers[0]^=numbers[1];
		numbers[1]=numbers[0]^numbers[1];
		numbers[0]=numbers[0]^numbers[1];
		return numbers;
	}
}
//leetcode submit region end(Prohibit modification and deletion)

}
